package com.neusoft.controller;

import com.neusoft.bean.PageBean;
import com.neusoft.service.RegisterDrugService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/druginfos")
@CrossOrigin
public class RegisterDrugController {

    @Autowired
    private RegisterDrugService registerDrugService;
    @GetMapping("/searchRegister")
    public PageBean searchRegister(@RequestParam(defaultValue = "1") Integer page,
                                   @RequestParam(defaultValue = "5") Integer pageSize,
                                   String caseNumber, String realName){
        return registerDrugService.searchRegister(page,pageSize,caseNumber,realName);
    }
    //    搜索患者信息不带换页方法
    //    public PageBean searchRegister(@RequestParam String caseNumber, String realName){
    //        return registerDrugService.searchRegister(caseNumber,realName);
    //    }
    @GetMapping("/showMedical")
    public PageBean showMedical(Integer registerId){
        return registerDrugService.showMedical(registerId);
    }

    //    发药
    @GetMapping("/giveMedical")
    public String giveMedical(Integer registerId){
        return registerDrugService.giveMedical(registerId);
    }

    //    退药  查询已退药的人
    @GetMapping("/searchDropRegister")
    public PageBean searchDropRegister(@RequestParam(defaultValue = "1") Integer page,
                                       @RequestParam(defaultValue = "5") Integer pageSize,
                                       String caseNumber, String realName){
        return registerDrugService.searchDropRegister(page,pageSize,caseNumber,realName);
    }

    @GetMapping("/showDropMedical")
    public PageBean showDropMedical(Integer registerId){
        return registerDrugService.showDropMedical(registerId);
    }
    @GetMapping("/refundMedical")
    public String refundMedical(Integer registerId,Integer drugId){
        return registerDrugService.refundMedical(registerId,drugId);
    }

}
